//
// Created by Administrator on 2024/4/9.
//
#include<bits/stdc++.h>

using namespace std;
int a[50][50];
int n;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int check(int x, int y) {
    return x >= 0 && x < n && y >= 0 && y < n && a[x][y] == 0;
}

int main() {
    cin >> n;
    int x = 0, y = -1;
    int k = 0, i = 0;
    while (k < n * n) {
        while (check(x + dx[i], y + dy[i]))
            a[x = x + dx[i]][y = y + dy[i]] = ++k;
        i = (i + 1) % 4;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << a[i][j] << " ";

        }
        cout << endl;
    }

    return 0;
}